/*
 * Tools.h
 *
 *  Created on: 2010-12-21
 *      Author: minhua
 */

#ifndef TOOLS_H_
#define TOOLS_H_

#include <QString>
#include <QDomElement>
#include <QDir>
#include <QStringList>
#include <QObject>

#define DELETE_LATER(obj) \
  (obj)->disconnect(); \
  (obj)->deleteLater();

class Tools
{
private:
	Tools();
	virtual ~Tools();
private:
	static void createFileElement(QDomElement& parent, const QDir& rootDir, const QDir& dir, QStringList ignoreFileSuffixList = QStringList());
public:
	static bool deleteFile(const QString filename);
	static bool deleteDir(const QString dirName);
	static bool copyDir(const QString& destDirPath, const QString& sourceDirPath);

	static bool deleteFiles(const QString& dirPath, const QString& str);

    static QByteArray encrypt(const QByteArray& data, const unsigned char* key, int keyLen);
    static QByteArray crypt(const QByteArray& data, const unsigned char* key,int keyLen);

	static bool package(const QString& rccProgram, const QString& dirPath, const QString& fileName, QStringList ignoreFileSuffixList = QStringList());
};

#endif /* TOOLS_H_ */
